package github.kawaiior.yuanchuxiuzhen.util;

import github.kawaiior.yuanchuxiuzhen.core.init.event.ModPlayerEvent;

public class ManaPowerHelper {

    public static final int MAX_LEVEL = 11;
    public static final int MAX_INNER_LEVEL = 4;

    private static final int baseExp = 20;
    private static final float[] expArray = new float[]{2F, 2.5F, 3F, 4F};

//    private static final int baseExp = 10;
//    private static final float[] expArray = new float[]{1F, 1.1F, 1.2F, 1.5F};

    // 最大值
    public static final int MAX_HEALTH = 1024;
    public static final int MAX_ATTACK = 256;

    /**
     * 通过等级来获取当前最大经验值
     */
    public static int getMaxExperience(int level, int innerLevel){
        if (level==0){
            return 20;
        }

        if (level <= 4){
            return (int)(baseExp * Math.pow(4D, level - 1) * expArray[innerLevel-1] + 0.5D);
        }
        if (level <= 8){
            return (int)(baseExp * Math.pow(4D, 3) * Math.pow(2D, level-4) * expArray[innerLevel-1] + 0.5D);
        }
        return (int)(baseExp * Math.pow(4D, 3) * Math.pow(2D, 4) * Math.pow(1.5D, level-8) * expArray[innerLevel-1] + 0.5D);
    }

    public static final int[][] healthBoost = new int[][]{
            {1, 1, 1, 1},{1, 1, 1, 1},{1, 1, 1, 1},{1, 1, 1, 1}, // 20 + 16
            {2, 2, 2, 2},{2, 2, 2, 2},{2, 2, 2, 2},{2, 2, 2, 2}, // 20 + 16 + 32
            {4, 4, 4, 5},{5, 5, 5, 5},{5, 10, 15, 15}, // 20 + 16 + 32 + 12 + 30 + 15 + 15
    };

    /**
     * 通过等级获取属性提升数值
     */
    public static int getHealthBoost(int level, int innerLevel){
        return healthBoost[level-1][innerLevel-1];
    }

    public static final int[][] manaBoost = new int[][]{
            {50, 50, 50, 50},{50, 50, 100, 100},{100, 100, 100, 100},{100, 200, 200, 200},
            {200, 400, 400, 400},{800, 800, 800, 800},{800, 1000, 1000, 1000},{1000, 1000, 1000, 1000},
            {1000, 2000, 2000, 2000},{2000, 3000, 3000, 3000},{3000, 4000, 4000, 6000}
    };

    public static float getMaxManaBoost(int level, int innerLevel){
        return manaBoost[level-1][innerLevel-1];
    }

    public static final float[][] attackBoost = new float[][]{
            {0.1F,0.1F,0.1F,0.1F},{0.1F,0.1F,0.1F,0.1F},{0.1F,0.1F,0.2F,0.2F},{0.2F,0.2F,0.2F,0.4F}, // 2
            {0.4F,0.4F,0.4F,0.4F},{0.8F,0.8F,0.8F,0.8F},{0.8F,1F,1F,1F},{1F,1F,1F,1F}, // 2 4
            {1F,1F,1F,1F},{1F,1F,1F,2F},{5F,5F,5F,10F} // 14 2 15 10
    };

    public static float getAttackBoost(int level, int innerLevel){
        return attackBoost[level-1][innerLevel-1];
    }

    public static final float[][] defenseBoost = new float[][]{
            {0.25F, 0.25F, 0.25F, 0.25F},{0.25F, 0.25F, 0.25F, 0.25F}, {0.25F, 0.25F, 0.5F, 0.5F},{0.5F, 0.5F, 0.5F, 0.5F},
            {0.5F, 0.5F, 0.5F, 0.5F},{0.5F, 0.5F, 0.5F, 0.5F},{0.5F, 1F, 1F, 1F},{1F, 1F, 1F, 1F},
            {1F, 1F, 1F, 2F}, {2F, 2F, 2F, 2F}, {5F, 5F, 10F, 10F}
    };

    public static float getDefenseBoost(int level, int innerLevel){
        return defenseBoost[level-1][innerLevel-1];
    }

    public static final float[][] manaRecoveryBoost = new float[][]{
            {0.5F,0.5F,0.5F,0.5F},{0.5F,0.5F,0.5F,0.5F},{0.5F,0.5F,1F,1F},{1F,1F,2F,2F},
            {2F,2F,2F,3F},{3F,3F,3F,3F},{4F,4F,4F,4F},{4F,5F,5F,5F},
            {5F,5F,5F,5F},{5F,5F,5F,5F},{10F,10F,10F,10F}
    };

    public static float getManaRecoveryBoost(int level, int innerLevel){
        return manaRecoveryBoost[level-1][innerLevel-1];
    }

    public static int getAverageLevelMultiple(){
        int averageLevel = ModPlayerEvent.averageLevel;
        if (averageLevel < 5){
            return 1;
        }
        else if (averageLevel < 10){
            return 2;
        }
        else if (averageLevel < 15){
            return 3;
        }
        else if (averageLevel < 20){
            return 4;
        }
        else if (averageLevel < 25){
            return 5;
        }
        else if (averageLevel < 30){
            return 6;
        }
        else if (averageLevel < 35){
            return 7;
        }
        else if (averageLevel < 40){
            return 8;
        }
        else if (averageLevel < 45){
            return 9;
        }
        return 10;
    }

}
